﻿package top.yangyitao.action;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;

import top.yangyitao.service.RegisterCodeService;
import top.yangyitao.service.UserService;

@SuppressWarnings("serial")
@Controller
public class EmailRegister extends ActionSupport {
	
	@Resource
	private RegisterCodeService registerCodeService;
	@Resource
	private UserService userService;
	private String errorMessage;
	public String getErrorMessage() {
		return errorMessage;
	}
	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}
	private String userName;
	private String code;
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Override
	public String execute() throws Exception {
		if(registerCodeService.checkRegisterCode(userName, code)) {
			userService.activeUser(userName);
			errorMessage="*激活成功!";
			return SUCCESS;
		}
		else {
			errorMessage="*超时或错误链接!请重新注册!";
			return ERROR;
			}
	}

}
